<?php
namespace app\common\behavior;
 
use think\Exception;
use think\Response;
 
class CronRun
{
  public function run(&$dispatch){
    $headers = [
      "Access-Control-Allow-Origin" => '*',
      "Access-Control-Allow-Methods" => '*',
      "Access-Control-Allow-Credentials" => 'true',
      "Access-Control-Allow-Headers" => "x-token,x-uid,x-token-check,x-requested-with,content-type,token,lang"
    ];

    if($dispatch instanceof Response) {
       $dispatch->header($headers);
    } else if($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
      $dispatch['type'] = 'response';
      $response = new Response('', 200, $headers);
      $dispatch['response'] = $response;
    }
  }
}